<!--智慧消防V1.0-list页面-->
<template>
    <div class="app-container">

        <uc-table url="admin/user/getUserSignPage" name="签到记录" ref="signTable" pageable table-border :search-form="searchForm">
            <template slot="searchForm">
                <el-form size="mini" :inline="true" :model="searchForm" class="demo-form-inline filter-container">

                    <el-form-item v-if="enterPriseHidden">
                        <el-select v-model="searchForm.flagId" placeholder="请选择主体" style="width: 100%" clearable @clear="clearInput1()">
                            <el-option v-for="(item,index) in enterpriseDominantList" :key="index"  :value="item.ucId" :label="item.name"></el-option>
                        </el-select>
                    </el-form-item>
                    <!--搜索按钮--新增按钮-->
                    <el-form-item>
                        <el-button v-if="enterPriseHidden" type="primary" icon="el-icon-search" class="filter-item" @click="handleSearch()">查询</el-button>
                    </el-form-item>
                </el-form>
            </template>
            <template slot="columns">
                <el-table-column prop="name" label="职工名称" align="left"></el-table-column>
                <el-table-column prop="enterpriseName" label="所属企业" align="left"></el-table-column>
                <el-table-column prop="signTime" label="签到时间" align="left">
                    <template slot-scope="slot">
                        {{slot.row.signTime|dateFormat}}
                    </template>
                </el-table-column>
                <el-table-column prop="signType" label="签到类型" align="left">
                    <template slot-scope="slot">
                        {{slot.row.signType |signType}}
                    </template>
                </el-table-column>
            </template>
        </uc-table>
    </div>
</template>

<script>
import UcTable from "@/components/UcTable/index.vue";
import {getInEnterpriseDominantList} from "@/api/enterpriseDominant";
export default {
    name: "list",
    components: {UcTable},
    data(){
        return{
            searchForm:{
                deleted:false
            },
            enterpriseDominantList:[]
        }
    },
    computed:{
        enterPriseHidden(){
            let roleCode = this.$store.getters.roleCode;
            console.log(roleCode)
            return roleCode=="XT-SUPER"||roleCode=="ADMIN"||roleCode=="XT-ADMIN"||roleCode=="ZD-ADMIN"
        }
    },
    created() {
        this.getInEnterpriseDominantList()
    },
    methods:{
        handleSearch(){
            this.$refs.signTable.getTableData(1)
        },
        clearInput1(){
            //清除输入框
            this.searchForm.flagId = null
            this.handleSearch()
        },
        getInEnterpriseDominantList(){
            getInEnterpriseDominantList({deleted:false}).then(res=>{
                this.enterpriseDominantList = res.data
            }).catch(error=>{
                console.log(error)
            })
        }
    }

}
</script>

<style scoped>

</style>
